package com.guys8.cemsbackend.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.guys8.cemsbackend.utils.MD5.Md5util;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.UUID;

/**
 * (Account)表实体类
 *
 * @author breeze
 * @since 2022-08-24 17:15:16
 */
@Setter
@Getter
@ToString
@Data
@Accessors(chain = true)
public class Account extends Model<Account> {

    @TableId(value = "account_id",type = IdType.AUTO)
    private Integer accountId;
    private String schoolId;
    private String password;
    //1-管理员，2-教师，3-学生，4-其他
    private Integer permissions;
    @TableLogic
    private Integer isDelete;
    private Integer ext1;
    //用户密码随机盐
    private String ext2;

    public Account(){}

    public Account(String schoolId,String password, Integer permissions){
        setSchoolId(schoolId);
        String salt = UUID.randomUUID().toString();//生成随机盐
        setExt2(salt);
        String passDB = Md5util.inputPassToDbPass(password,salt);//二次加密后密码
        setPassword(passDB);
        setPermissions(permissions);
        setIsDelete(0);
    }

}

